package com.distribute.domain.service;

import com.distribute.config.distributeLock.DistributedLock;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class DistributedService {

    @DistributedLock(key = "#id", expiration = 10000, timeout = 30000)
    public String testDistributeLock(String id) {
        log.info("lock id: {}：enter test distribute lock method...", id);
        try {
            Thread.sleep(35000);
            return "process timeout!";
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

//        try {
//            Thread.sleep(18000);
//        } catch (InterruptedException e) {
//            e.printStackTrace();
//        }
        return "process successful!";
    }
}
